package com.companyName.sample.common.bean;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.Serializable;

import com.companyName.sample.common.constant.ResponseMsg;

/**
 * Created by guo.jun on 2016/3/28.
 */
public class ResponseDataFast<T> implements Serializable {

    private static final long serialVersionUID = 6508077198622317999L;

    int code;

    T result;

    String desc;

    String message;

    public ResponseDataFast(int code, T result) {
        this.code = code;
        this.result = result;
    }

    public ResponseDataFast(int code, T result, String message) {
        this.code = code;
        this.result = result;
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public boolean success() {
        return this.code == ResponseMsg.SUCCESS.getCode();
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteDateUseDateFormat);
    }
}
